using System;
using System.Collections.Generic;
using System.ComponentModel;

namespace CSW.Framework.UI.Binding
{
    /// <summary>
    /// ITypedGridController interface.
    /// </summary>
    /// <typeparam name="T">The item type.</typeparam>
    public interface ITypedGridController<T> : IDisposable
        where T : class, INotifyPropertyChanged
    {
        /// <summary>
        /// Gets the selected object if one and only one row is selected; otherwise, returns <c>null</c>.
        /// </summary>
        /// <returns>The selected object if one and only one row is selected; otherwise, returns <c>null</c>.</returns>
        T GetSelectedObject();

        /// <summary>
        /// Gets the selected objects.
        /// </summary>
        /// <returns>The selected objects.</returns>
        List<T> GetSelectedObjects();

        /// <summary>
        /// Selects a single row.
        /// </summary>
        /// <param name="item">The item.</param>
        void SelectSingleRow(T item);

        /// <summary>
        /// Deselects a row.
        /// </summary>
        /// <param name="item">The item.</param>
        void DeselectRow(T item);

        /// <summary>
        /// Gets or sets the data source.
        /// </summary>
        /// <value>The data source.</value>
        BindingList<T> DataSource { get; }

        /// <summary>
        /// Best fits the columns.
        /// </summary>
        void BestFitColumns();

        /// <summary>
        /// Clears the selection.
        /// </summary>
        void ClearSelection();

        /// <summary>
        /// Gets the row count.
        /// </summary>
        /// <value>The row count.</value>
        int RowCount { get; }
    }
}
